package gitlet;

import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.nio.file.Files;
/**
 * @program: cs61b-sp21
 * @description: define the datastruct of a blob
 * @Author: Mark Zhang
 * @Date: 4/18/2024
 **/

public class Blob implements Serializable {
    //the file reference of the blob
    private File file;
    //the HID of the blob
    private String HID;

    public Blob(File file) {
        this.file = file;
        try {
            byte[] content = Files.readAllBytes(file.toPath());
            this.HID = Utils.sha1(content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public File getFile() {
        return file;
    }

    public String getHash() {
        return HID;
    }
}
